import {Request, Response, NextFunction} from "express";

const errorStatus = -1;
const errorMiddleware = (error: any, req: Request, res: Response, next: NextFunction) => {
  const status = error.status || errorStatus;
  const message = error.message;

  res.send({
    code: status,
    message,
    errors: error.errors
  });
  next();
};


export default errorMiddleware;